package cn.tedu.csmall.stock.webapi.service.impl;

import cn.tedu.csmall.commons.pojo.stock.dto.StockReduceCountDTO;
import cn.tedu.csmall.stock.service.IStockService;
import cn.tedu.csmall.stock.webapi.mapper.StockMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

// @DubboService 注解表示当前业务逻辑层实现类中的所有方法
//均会注册到nacos，成功Dubbo可以被发现的业务逻辑层方法
@DubboService
@Service
@Slf4j
public class StockServiceImpl implements IStockService {

    @Autowired
    private StockMapper stockMapper;


    @Override
    public void reduceCommodityCount(StockReduceCountDTO stockReduceCountDTO) {

        stockMapper.updateStockByCommodityCode(
              stockReduceCountDTO.getCommodityCode(),
                stockReduceCountDTO.getReduceCount()
        );
        log.info("减少库存完成！！！");
    }


}
